package com.csesteel.crm.dao.impl;

import com.csesteel.common.dao.impl.BaseDaoHibernate4;
import com.csesteel.crm.dao.UserDao;
import com.csesteel.crm.domain.User;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2015/4/21 0021.
 */
public class UserDaoImpl extends BaseDaoHibernate4<User>
        implements UserDao
{
        public User getUserByNameAndPassword(User user) {
                List<User> users = find("select u from User u where u.username = ?0 and u.password = ?1"
                        , user.getUsername(),user.getPassword());
                if (users!= null && users.size() >= 1)
                {
                        return users.get(0);
                }
                return null;
        }

        public User getUserByNameAndPassword(String name, String passwd) {
                List<User> users = find("select u from User u where u.username = ?0 and u.password = ?1"
                        , name,passwd);
                if (users!= null && users.size() >= 1)
                {
                        return users.get(0);
                }
                return null;
        }

        public void deleteUserById(String id) {
                String deletesql = "delete from cse_user where id = "+id;
                deleteBySQL(deletesql);
        }
}
